package com.coolweather.android;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.coolweather.android.db.City;
import com.coolweather.android.db.County;
import com.coolweather.android.db.Province;

import org.litepal.tablemanager.Connector;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
//        Log.d("123","321");

        Button bt1=findViewById(R.id.createDatabase);

        bt1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.d("触发点击","info");
                Connector.getDatabase();
            }
        });
        Button bt2=findViewById(R.id.city);
        bt2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                City city = new City();
                city.setId(222);
                city.setCityName("眉山区");
                city.setCityCode(2);
                city.setProvinceId(2);
                city.save();

            }
        });
        Button bt3=findViewById(R.id.county);
        bt3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                 County county =new County();
                county.setId(333);
                county.setCountyName("彭山区");
                county.setWeatherId("3");
                county.setCityId(3);
                county.save();
            }
        });
        Button bt4=findViewById(R.id.province);
        bt4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Province province = new Province();
                province.setId(111);
                province.setProvinceName("四川省");
                province.setProvinceCode(1);
                province.save();

            }
        });



    }
}